<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateKfConfigTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    private $tableName = 'config';
    public function up()
    {
        Schema::create($this->tableName, function (Blueprint $table) {
            $table->id();
            $table->string('name', 30)->default('');
            $table->string('key', 30)->default('');
            $table->string('value', 200)->default('');
            $table->string('type', 30)->default('');
            $table->string('remark', 30)->default('');
            $table->integer("createdAt")->default(0)->unsigned()->comment("创建时间");
            $table->integer("updatedAt")->default(0)->unsigned()->comment("更新时间");
            $table->tinyInteger('isDeleted')->default(0)->comment('是否删除 0否 1是');
            $table->index(['type', 'key'], 'typeKeyIdx');
            $table->index('name', 'nameIdx');
            $table->collation = 'utf8mb4_general_ci';
        });

        $prefix = config('other.DB_PREFIX','');
        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `{$prefix}{$this->tableName}` COMMENT = '系统配置表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists($this->tableName);
    }
}
